package com.brillilab.service.job.lab;

import com.brillilab.service.logic.message.MessageLogic;
import com.brillilab.service.module.aliyun.AliYunSms;
import com.brillilab.service.module.message.producer.MessageProducer;
import com.brillilab.service.module.message.template.impl.lab.BeforeLabExpireTemplate;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
@Component
public class WhenLabExpireJob implements Job {

    @Autowired
    private MessageLogic messageLogic;
    @Autowired
    private AliYunSms aliYunSms;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap dataMap=context.getJobDetail().getJobDataMap();
        String labName=dataMap.getString("labName");
        String userName=dataMap.getString("userName");
        String mobile=dataMap.getString("mobile");
        // 短信逻辑
        Map<String,Object> temMap = new HashMap<>();
        temMap.put("labName",labName);
        temMap.put("userName",userName);
        messageLogic.sendSmsContent(mobile,aliYunSms.getWhenLabExpireTemplate(),temMap);
    }
}